package org.example.controller;



import org.example.pojo.Result;
import org.example.service.IResulrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class ResultController {
    @Autowired
    private IResulrService resulrService;

    @RequestMapping("/save")
    @ResponseBody
    public String save(){
        Result result = new Result();
        result.setId(1);
        result.setStudentid(1);
        result.setStatus("0");
        result.setScore(100);
        resulrService.save(result);
        return "save success";
    }

    @RequestMapping("/saveResult/{id}/{score}")
    @ResponseBody
    public String saveResult(@PathVariable(name = "id") int id, @PathVariable(name = "score") int score){
        Result result = new Result();
        result.setId(id);
        result.setStudentid(1);
        result.setStatus("0");
        result.setScore(score);
        try {
            resulrService.saveResult(result);
        }catch (Exception e){
            return "save fail";
        }
        return "save success";
    }
}
